<template>
    <div>
        <el-table
            ref="customerTable"
            :data="tableData"
            stripe
            border
            v-loading="loading"
            style="width: 100%"
            @selection-change="getSelectVal"
        >
            <el-table-column type="selection" width="55" align="center">
            </el-table-column>
            <el-table-column
                type="index"
                label="序号"
                width="55"
                align="center"
            />
            <el-table-column
                prop="conditionCode"
                label="编码"
            ></el-table-column>
            <el-table-column prop="title" label="名称"></el-table-column>
            <el-table-column prop="deptId" label="所属公司"></el-table-column>

            <el-table-column prop="type" label="类型">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.dueSetStandard === 1"
                        >收款条件</el-tag
                    >
                    <el-tag v-if="scope.row.dueSetStandard === 2"
                        >付款条件</el-tag
                    >
                </template>
            </el-table-column>
            <el-table-column prop="dueSetStandard" label="到期日设置标准">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.dueSetStandard === 1"
                        >按比例</el-tag
                    >
                    <el-tag v-if="scope.row.dueSetStandard === 2"
                        >按金额</el-tag
                    >
                </template>
            </el-table-column>
            <el-table-column prop="dueTime" label="到期日计算日期">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.dueSetStandard === 1"
                        >订单日期</el-tag
                    >
                    <el-tag v-if="scope.row.dueSetStandard === 2"
                        >应收单业务日期</el-tag
                    >
                    <el-tag v-if="scope.row.dueSetStandard === 3"
                        >出库日期</el-tag
                    >
                </template>
            </el-table-column>
            <el-table-column prop="receiptType" label="收款方式">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.dueSetStandard === 1"
                        >按到期日收款</el-tag
                    >
                    <el-tag v-if="scope.row.dueSetStandard === 2"
                        >按订单收款</el-tag
                    >
                    <el-tag v-if="scope.row.dueSetStandard === 3"
                        >按物料明细收款</el-tag
                    >
                </template>
            </el-table-column>
            <el-table-column
                prop="conditionDesc"
                label="描述"
            ></el-table-column>
        </el-table>
        <el-pagination
            class="pagination mt10"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            background
        >
        </el-pagination>
    </div>
</template>

<script>
import { getPayData } from "@/api/base/data";
export default {
    data() {
        return {
            tableData: [],
            currentPage: 1, //当前页
            limit: 10, //每页条数
            total: 0,
            loading: false,
        };
    },
    methods: {
        //分页器size
        handleSizeChange(val) {
            this.limit = val;
            this.getDataList();
        },
        //分页器当前页
        handleCurrentChange(val) {
            this.currentPage = val;
            this.getDataList();
        },
        getSelectVal(val) {
            if (val.length) {
                this.$emit("update:visible", false);
                this.$emit("getSelectVal", val);
            }
        },
        getDataList() {
            this.loading = true;
            let parmas = {
                page: this.page,
                limit: this.limit,
                type: 1,
            };
            getPayData(parmas).then((res) => {
                this.tableData = res.rows;
                this.total = res.total;
                this.loading = false;
            });
        },
    },
    mounted() {
        this.getDataList();
    },
};
</script>

<style></style>
